home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch18 / lightr / opt2scn.awk < prev    next >
Text File  |  1993-07-05  |  989b  |  61 lines

  1. /^\/\*/ {
  2.   print ";", substr($0, 4)
  3.   next
  4. }
  5.  
  6. /look[fF]rom/ {
  7.   print "from", $2, $3, $4
  8.   print "light point", $2, $3, $4, "mono 0.5"
  9.   next
  10. }
  11.  
  12. /look[aA]t/ {
  13.   print "at", $2, $3, $4
  14.   next
  15. }
  16.  
  17. /look[uU]p/ {
  18.   print "up", $2, $3, $4
  19.   next
  20. }
  21.  
  22. $1 == "fovx" {
  23.   print "fov", $2/2.0, $4/2.0
  24.   print "background black"
  25.   print "ambient white"
  26.   next
  27. }
  28.  
  29. /^add object/ {
  30.   name = $3
  31.   nv = 0
  32.   getline
  33.   while ($0 != "end") {
  34.     nv++
  35.     if (nv > 4) {
  36.       print "; polygon", name, "ignored (more than 4 vertices)"
  37.       next
  38.     }
  39.     v[nv] = $2" "$3" "$4" "$5" "$6" "$7
  40.     getline
  41.   }
  42.   getline
  43.   cr = $4
  44.   cg = $5
  45.   cb = $6
  46.   ks = $9
  47.   kd = $10
  48.   getline
  49.   printf "surface %g %g %g mono %g mono %g 0 0\n", cr, cg, cb, kd, ks
  50.   print "triangle normal ; polygon", name
  51.   print v[1]
  52.   print v[2]
  53.   print v[3]
  54.   if (nv == 3) next
  55.   print "triangle normal ; polygon", name, "(part 2)"
  56.   print v[3]
  57.   print v[4]
  58.   print v[1]
  59.   next
  60. }
  61.